<?php
declare (strict_types=1);

namespace Plugin\Alarm\Model;

use Mine\MineModel;
use Plugin\Alarm\Model\RdAlarmDangerType;

class RdAlarmDanger extends MineModel
{
    /**
     * The table associated with the model.
     *
     * @var string|null
     */
    protected ?string $table = 'rd_alarm_danger';
    
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected array $fillable = [
        'id', 'type', 'stand_id', 'camera_id', 'addr', 'from_type', 'severity', 
        'extra', 'status', 'work_id', 'created_by', 'updated_by', 'created_at', 'updated_at'
    ];
    
    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected array $casts = [
        'id' => 'integer',
        'type' => 'integer',
        'stand_id' => 'integer',
        'camera_id' => 'integer',
        'addr' => 'string',
        'from_type' => 'integer',
        'severity' => 'integer',
        'extra' => 'array',
        'status' => 'integer',
        'work_id' => 'integer',
        'created_by' => 'integer',
        'updated_by' => 'integer',
        'created_at' => 'datetime',
        'updated_at' => 'datetime',
    ];
    
    /**
     * 关联隐患类别
     */
    public function dangerType()
    {
        return $this->belongsTo(RdAlarmDangerType::class, 'type', 'id');
    }
}